let form = layui.form
// 获取id
let id = location.search.substring(4)
// console.log(id);

function getUserInfo() {
    $.ajax({
        url:'/admin/users/'+id,
        success: function(res) {
            // console.log(res);
            if (res.status === 0) {
                form.val('editForm',res.data)
            } else {
                layer.msg(res.message)
            }
        }
    })
}

getUserInfo()


// let fd = new FormData()
$('form').on('submit',function(e) {
    e.preventDefault()
    let fd = $(this).serialize()
    // console.log(111);
    $.ajax({
        type:'put',
        url: '/admin/users',
        data: fd,
        success: function(res) {
            console.log(res);
            layer.msg(res.message)
            if (res.status === 0) {
                location.href = '../user/user.html'
             }

        }
    })
})